package com.youlu.campus.admin.zm.controller;

import com.youlu.campus.admin.zm.req.ZmReceiveMsgRequest;
import com.youlu.campus.admin.zm.service.ZmApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : [dengbo]
 * @className : ZmApiController
 * @description : [芝麻客服]
 * @createTime : [2022/11/9 17:49]
 */
@RequestMapping("/zm/api")
@RestController
@Slf4j
public class ZmApiController {

    @Autowired
    private ZmApiService zmApiService;

    /**
     * 芝麻客服退款消息接收
     * openapi@dingtalk
     *
     * @return
     */
    @PostMapping(value = "/refund")
    public Object refund(@RequestBody ZmReceiveMsgRequest req) throws Exception {
        log.info("openId:{},refund request param:{}", req.getOpenid(), req);
        return zmApiService.zmReceive(req);
    }

    /**
     * 订单信息查询
     * openapi@dingtalk
     *
     * @return
     */
    @PostMapping(value = "/query")
    public Object query(@RequestBody ZmReceiveMsgRequest req) throws Exception {
        log.info("openId:{},query request param:{}", req.getOpenid(), req);
        return zmApiService.query(req);
    }
}
